package com.clz.servlet;

import com.jspsmart.upload.SmartUpload;
import com.jspsmart.upload.SmartUploadException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/pica")
public class picService extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //创建对象
        SmartUpload sm=new SmartUpload();
        //初始化
        sm.initialize(this.getServletConfig(),req,resp);
        sm.setCharset("UTF-8");
        try {
            sm.upload();
            sm.save("/pict");
            System.out.println("保存成功");
        } catch (Exception e) {
           e.printStackTrace();
        }
    }
}
